class Admin::PagesController < AdminController
  
  
  def index
    @pages = Page.all
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @pages }
    end  
  end
  
  def show
    @page = Page.find(params[:id])
    respond_to do |format|
      format.html # show.html.erb
      format.fbml
      format.xml  { render :xml => @page }
    end
    
  end
  
  
  def new
    @page = Page.new
  end
  
  def create
    @page = Page.new(params[:page]) 
    if @page.save
      flash_notice(:page_created)
      redirect_to admin_pages_url
    else
      render :action=>:new
    end
  end
  
  def destroy
    @page = Page.find(params[:id])
    @page.destroy
    
    flash_notice(:page_removed)
    respond_to do |format|
      format.html { redirect_to(admin_pages_url) }
      format.xml  { head :ok }
    end
  end
  
  def edit
    @page = Page.find(params[:id])
  end
  
  def update
    @page = Page.find(params[:id])
    respond_to do |format|
      if @page.update_attributes(params[:page])
        
        flash_notice(:page_updated)
        format.html { redirect_to admin_page_url(@page) }
        format.xml  { head :ok }
      else
        flash_error(:page_not_updated)
        format.html { render :action => "edit" }
        format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
      end
    end
    
  end
end
